﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PropertyGrid控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.propertyGrid1.SelectedObject = this.dispTextControl1;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Station s = new Station();
            this.propertyGrid1.SelectedObject = s;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            PropertyManageCls pmc = new PropertyManageCls();
            Property pp = new Property("ID", "1", false, true);
            pp.Category = "基本信息";
            pp.DisplayName = "我的ID";
            pmc.Add(pp);
            this.propertyGrid1.SelectedObject = pmc;
        }

        private void button4_Click(object sender, EventArgs e)
        {

            PropertyManageCls pmc = new PropertyManageCls();
            string[] s = new string[] { "1", "2", "3", "4" };
            Property pp = new Property("ID", "1", false, true);
            pp.Category = "基本信息";
            pp.DisplayName = "我的ID";
            pp.Converter = new DropDownListConverter(s);//Property的Converter属性就可以设置类型转换
            pmc.Add(pp);
            propertyGrid1.SelectedObject = pmc;

        }

        private void button5_Click(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = new ShowedClass() { Name = "TEST" };
        }

        ShowInformation Information = new ShowInformation() { Name = "TEST" };
        private void button6_Click(object sender, EventArgs e)
        {
            propertyGrid1.SelectedObject = Information;
        }

        private void button7_Click(object sender, EventArgs e)
        {
            if (Information.Name == "TEST_1")
            {
                Information.doSome[0]();
            }
            else if (Information.Name == "TEST_2")
            {
                Information.doSome[1]();
            }
            else if (Information.Name == "TEST_3")
            {
                Information.doSome[2]();
            }
        }
    }
}
